package pl.msikora.android.lapmagic.database;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TracksTable {
	
	private static final String TAG = "TracksTable";
	
	public static final String TABLE_TRACKS = "tracks";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_NAME = "name";
	
	private static final String TABLE_CREATE = "create table "
			+ TABLE_TRACKS
			+ "(" 
			+ COLUMN_ID + " integer primary key autoincrement, "
			+ COLUMN_NAME + " text default 'track'"
			+ ");";
	
	public static void onCreate(SQLiteDatabase database) {
		Log.d(TAG, "creating table tracks with statement '" + TABLE_CREATE
				+ "'");
		database.execSQL(TABLE_CREATE);
	}
	
	public static void onUpgrade(SQLiteDatabase database, int oldVersion, 
			int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion
				+ " to " + newVersion 
				+ ", which will destroy new all old data");
		database.execSQL("drop table if exists " + TABLE_TRACKS);
		onCreate(database);
	}

}
